<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>session存储配置</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base_new.css'); }
    {php echo Common::getScript('config.js');}
</head>
<body>

	<table class="content-tab">
        <tr>
            <td width="119px" class="content-lt-td"  valign="top">
                {template 'stourtravel/public/leftnav'}
                <!--右侧内容区-->
            </td>
            <td valign="top" class="content-rt-td">
                <form id="configfrm">
                    <div class="w-set-con">
                    	<div class="cfg-header-bar">
                            <div class="cfg-header-tab">
                                <span class="item on">session存储配置<img class="ml-5" style="cursor:pointer; vertical-align: middle; margin-top: -3px;" title="查看帮助cfg_session_config" src="/newtravel/public/images/help-ico.png" onclick="ST.Util.helpBox(this,'cfg_session_config',event)"></span>
                            </div>
                    		<a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>
                    	</div>
        
                        <div class="w-set-nr">
                            <ul class="info-item-block">
                                <li>
                                    <span class="item-hd">session存储</span>
                                    <div class="item-bd">
                                        <label class="radio-label ml-20 storage-config"><input type="radio" name="cfg_session_driver" value="native" {if $config['cfg_session_driver']=='native' || empty($config['cfg_session_driver'])}checked{/if}>文件</label>
                                        <label class="radio-label ml-20 storage-config"><input type="radio" name="cfg_session_driver" value="database" {if $config['cfg_session_driver']=='database'}checked{/if}>数据库</label>
                                        <label class="radio-label ml-20 storage-config"><input type="radio" name="cfg_session_driver" value="redis" {if $config['cfg_session_driver']=='redis'}checked{/if}>Redis</label>
                                    </div>
                                </li>

                                <li class="redis_item" {if $config['cfg_session_driver'] != 'redis'}style="display:none"{/if}>
                                    <span class="item-hd">Redis 主机：</span>
                                    <div class="item-bd">
                                        <input type="text" name="cfg_session_redis_host" id="cfg_session_redis_host" class="input-text w150" value="{$config['cfg_session_redis_host']}" placeholder="如116.15.16.25" >
                                    </div>
                                </li>
                                <li class="redis_item" {if $config['cfg_session_driver'] != 'redis'}style="display:none"{/if}>
                                    <span class="item-hd">Redis 端口：</span>
                                    <div class="item-bd">
                                        <input type="text" name="cfg_session_redis_port" id="cfg_session_redis_port" class="input-text w150" value="{$config['cfg_session_redis_port']}" placeholder="6379" autocomplete="off" >
                                    </div>
                                </li>
                                <li class="redis_item" {if $config['cfg_session_driver'] != 'redis'}style="display:none"{/if}>
                                    <span class="item-hd">Redis 密码：</span>
                                    <div class="item-bd">
                                        <input type="text" name="cfg_session_redis_password" id="cfg_session_redis_password" class="input-text w150" value="{$config['cfg_session_redis_password']}" placeholder="填写密码" autocomplete="off" >
                                    </div>
                                </li>
                                <li class="redis_item" {if $config['cfg_session_driver'] != 'redis'}style="display:none"{/if}>
                                    <span class="item-hd">库编号(0-15)：</span>
                                    <div class="item-bd">
                                        <input type="text" name="cfg_session_redis_database" id="cfg_session_redis_database" class="input-text w150" value="{$config['cfg_session_redis_database']}" placeholder="1" autocomplete="off" >
                                    </div>
                                </li>
                            </ul>

                            <div class="clear clearfix mt-20">
                                <a class="btn btn-primary radius size-L ml-115" href="javascript:;" id="btn_save">保存</a>
                                <!-- <a class="cancel" href="#">取消</a>-->
                                <input type="hidden" name="webid" id="webid" value="0">
                            </div>

                        </div>
                    </div>
                </form>

            </td>
        </tr>
    </table>

	<script>

	$(document).ready(function(){

	    $('.storage-config').click(function(){
	        var driver = $(this).find('input').val();
	        if(driver == 'redis'){
	            $('.redis_item').show();
            }else{
                $('.redis_item').hide();
            }
        })

        //配置信息保存
        $("#btn_save").click(function(){
            var url = SITEURL+"distribute/ajax_save_session";
            var frmdata = $("#configfrm").serialize();
            $.ajax({
                type:'POST',
                url:url,
                dataType:'json',
                data:frmdata,
                success:function(data){
                    if(data.status){
                        ST.Util.showMsg('保存成功',4);
                    }else{
                        ST.Util.showMsg(data.msg,5);
                    }
                }
            })

        })
    });
    </script>

</body>
</html>
